package main

import (
	"context"
	"fmt"
	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials/insecure"
	"log"
	"study01/pb"
)

func main() {
	dial, err := grpc.Dial(":8002", grpc.WithTransportCredentials(insecure.NewCredentials()))
	if err != nil {
		log.Fatal("服务端报错", err)
	}
	defer dial.Close()
	client := pb.NewProductServiceClient(dial)
	request := &pb.ProductRequest{ProdId: 100}
	response, err := client.GetProductStock(context.Background(), request)
	if err != nil {
		log.Fatal("查询库存出错", err)
	}
	fmt.Println("查询成功", response)
}
